window.icons = {
    refresh: 'bx bx-sync',
    columns: 'bx bx-list-ul',
    toggleOn: 'bx bx-toggle-right',
    toggleOff: 'bx bx-toggle-left',
    fullscreen: 'bx bx-expand'
}
    
$(document).ready(function(){
    var clipboard = new ClipboardJS('#copylink', {
        container: document.getElementById('qudaoModal')
    });
    clipboard.on('success', function(e) {
        var noticetext = $("#copylink").attr("text");
        mviewToastr("success",noticetext+"复制成功，粘贴即可获取!");
    });

    var copypath = new ClipboardJS('#copypath');
    copypath.on('success', function(e) {
        var noticetext = $("#copypath").attr("text");
        mviewToastr("success",noticetext+"复制成功，粘贴即可获取!");
    });

    statisticsDate("sevenday");
    qrcodesTotalStatistic();
    renderPlatformType();
});

$('#statisticsdate').daterangepicker({
    "autoUpdateInput":false,
    "autoApply": true,
    "minYear": 2020,
    "maxYear": moment().format("YYYY"),
    "locale": {
        "format": "YYYY-MM-DD",
        "separator": " - ",
        "applyLabel": "Apply",
        "cancelLabel": "Cancel",
        "fromLabel": "From",
        "toLabel": "To",
        "customRangeLabel": "Custom",
        "weekLabel": "W",
        "daysOfWeek": ["日","一","二","三","四","五","六"],
        "monthNames": ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
        "firstDay": 1
    },
    "startDate": moment().subtract(7, "days").format("YYYY-MM-DD"),
    "endDate": moment().format("YYYY-MM-DD"),
    "minDate": moment().format($("#created_at").val(),"YYYY-MM-DD"),
    "maxDate": moment().format("YYYY-MM-DD"),
    "opens": "left"
});

$('#statisticsdate').on('apply.daterangepicker', function(ev, picker) {
    var startTime = picker.startDate.format('YYYY-MM-DD');
    var endTime = picker.endDate.format('YYYY-MM-DD 23:59:59');
    $("#statistics_start").val(startTime);
    $("#statistics_end").val(endTime);
    var diffday = moment(endTime).diff(moment(startTime), "days");
    $("#statistics_day").val(diffday);
    $(this).val(picker.startDate.format('YYYY-MM-DD') +' 至 '+picker.endDate.format('YYYY-MM-DD'));
});

$('#recordDatePicker').daterangepicker({
    "autoUpdateInput":false,
    "autoApply": true,
    "minYear": 2020,
    "maxYear": moment().format("YYYY"),
    "locale": {
        "format": "YYYY-MM-DD",
        "separator": " - ",
        "applyLabel": "Apply",
        "cancelLabel": "Cancel",
        "fromLabel": "From",
        "toLabel": "To",
        "customRangeLabel": "Custom",
        "weekLabel": "W",
        "daysOfWeek": ["日","一","二","三","四","五","六"],
        "monthNames": ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
        "firstDay": 1
    },
    "startDate": moment().subtract(7, "days").format("YYYY-MM-DD"),
    "endDate": moment().format("YYYY-MM-DD"),
    "minDate": moment().format($("#created_at").val(),"YYYY-MM-DD"),
    "maxDate": moment().format("YYYY-MM-DD"),
    "opens": "left"
});

$('#recordDatePicker').on('apply.daterangepicker', function(ev, picker) {
    var startTime = picker.startDate.format('YYYY-MM-DD');
    var endTime = picker.endDate.format('YYYY-MM-DD 23:59:59');
    $("#record_data_start").val(startTime);
    $("#record_data_end").val(endTime);
    $(this).val(picker.startDate.format('YYYY-MM-DD') +' 至 '+picker.endDate.format('YYYY-MM-DD'));
});

$('#recordExportDatePicker').daterangepicker({
    "autoUpdateInput":false,
    "autoApply": true,
    "minYear": 2020,
    "maxYear": moment().format("YYYY"),
    "locale": {
        "format": "YYYY-MM-DD",
        "separator": " - ",
        "applyLabel": "Apply",
        "cancelLabel": "Cancel",
        "fromLabel": "From",
        "toLabel": "To",
        "customRangeLabel": "Custom",
        "weekLabel": "W",
        "daysOfWeek": ["日","一","二","三","四","五","六"],
        "monthNames": ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
        "firstDay": 1
    },
    "startDate": moment().subtract(7, "days").format("YYYY-MM-DD"),
    "endDate": moment().format("YYYY-MM-DD"),
    "minDate": '2023-05-10',
    "maxDate": moment().format("YYYY-MM-DD"),
    "opens": "left"
});

$('#recordExportDatePicker').on('apply.daterangepicker', function(ev, picker) {
    var startTime = picker.startDate.format('YYYY-MM-DD');
    var endTime = picker.endDate.format('YYYY-MM-DD 23:59:59');
    $("#record_export_start").val(startTime);
    $("#record_export_end").val(endTime);
    $(this).val(picker.startDate.format('YYYY-MM-DD') +' 至 '+picker.endDate.format('YYYY-MM-DD'));
});